/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.source.entity.direction;

import com.google.common.collect.Lists;
import com.thinkgem.jeesite.common.persistence.DataEntity;
import com.thinkgem.jeesite.modules.sys.entity.User;

import org.hibernate.validator.constraints.Length;

import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlList;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * 方向资源管理Entity
 * @author ZC
 * @version 2017-04-24
 */
@XmlRootElement(name="directcfg")
public class EleSourceDirectionGroup extends DataEntity<EleSourceDirectionGroup> {
	
	private static final long serialVersionUID = 1L;
	private String name;		// 名称
	private String stop;		// 静止图片
	private String upstop;		// 上行静止图片
	private String uptips;		// 上行到达音
	private String downstop;		// 下行静止图片
	private String downtips;		// 下行到达音
	private String deftips;		// 默认声音
	private String doublestop;		// 双向静止图片
	private List<EleSourceDirection> eleSourceDirectionList = Lists.newArrayList();		// 子表列表
	private List<EleSourceDirection> upnodeSources = Lists.newArrayList();	
		
	private List<EleSourceDirection> uplist = Lists.newArrayList();
	private List<EleSourceDirection> downlist = Lists.newArrayList();

	private List<String> upnodes = Lists.newArrayList();
	private List<String> downnodes = Lists.newArrayList();

	private List<EleSourceDirection> downnodeSources = Lists.newArrayList();
	
	public EleSourceDirectionGroup() {
		super();
	}

	public EleSourceDirectionGroup(String id){
		super(id);
	}
	public List<User> users = null;

	@XmlTransient
	public List<User> getUsers() {
		return users;
	}

	public void setUsers(List<User> users) {
		this.users = users;
	}
	@XmlTransient
	@Length(min=0, max=50, message="视频名称长度必须介于 0 和 50 之间")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@XmlElement(name = "stop")
	@Length(min=0, max=255, message="静止图片长度必须介于 0 和 255 之间")
	public String getStop() {
		return stop;
	}

	public void setStop(String stop) {
		this.stop = stop;
	}
	
	@XmlElement(name = "upstop")
	@Length(min=0, max=255, message="上行静止图片长度必须介于 0 和 255 之间")
	public String getUpstop() {
		return upstop;
	}

	public void setUpstop(String upstop) {
		this.upstop = upstop;
	}
	
	@XmlElement(name = "uptips")
	@Length(min=0, max=255, message="上行到达音长度必须介于 0 和 255 之间")
	public String getUptips() {
		return uptips;
	}

	public void setUptips(String uptips) {
		this.uptips = uptips;
	}
	
	@XmlElement(name = "downstop")
	@Length(min=0, max=255, message="下行静止图片长度必须介于 0 和 255 之间")
	public String getDownstop() {
		return downstop;
	}

	public void setDownstop(String downstop) {
		this.downstop = downstop;
	}

	@XmlElement(name = "doublestop")
	@Length(min=0, max=255, message="双向静止图片长度必须介于 0 和 255 之间")
	public String getDoublestop() {
		return doublestop;
	}

	public void setDoublestop(String doublestop) {
		this.doublestop = doublestop;
	}

	@XmlElement(name = "downtips")
	@Length(min=0, max=255, message="下行到达音长度必须介于 0 和 255 之间")
	public String getDowntips() {
		return downtips;
	}

	public void setDowntips(String downtips) {
		this.downtips = downtips;
	}
	
	@XmlElement(name = "deftips")
	@Length(min=0, max=255, message="默认声音长度必须介于 0 和 255 之间")
	public String getDeftips() {
		return deftips;
	}

	public void setDeftips(String deftips) {
		this.deftips = deftips;
	}

	
	
	public List<EleSourceDirection> getUpnodeSources() {
		return upnodeSources;
	}

	public void setUpnodeSources(List<EleSourceDirection> upnodeSources) {
		this.upnodeSources = upnodeSources;
	}
	@XmlElementWrapper(name="upnodes")
	@XmlElement(name = "node")
	public List<String> getUpnodes() {
		return upnodes;
	}

	public void setUpnodes(List<String> upnodes) {
		this.upnodes = upnodes;
	}
	@XmlElementWrapper(name="downnodes")
	@XmlElement(name = "node")
	public List<String> getDownnodes() {
		return downnodes;
	}

	public void setDownnodes(List<String> downnodes) {
		this.downnodes = downnodes;
	}

	@XmlTransient
	public List<EleSourceDirection> getUplist() {
		return uplist;
	}

	public void setUplist(List<EleSourceDirection> uplist) {
		this.uplist = uplist;
	}
	@XmlTransient
	public List<EleSourceDirection> getDownlist() {
		return downlist;
	}

	public void setDownlist(List<EleSourceDirection> downlist) {
		this.downlist = downlist;
	}

	public List<EleSourceDirection> getDownnodeSources() {
		return downnodeSources;
	}

	public void setDownnodeSources(List<EleSourceDirection> downnodeSources) {
		this.downnodeSources = downnodeSources;
	}

	public void devide(){
		for(EleSourceDirection esd: eleSourceDirectionList){
			if("up".equals(esd.getDirection())){
				upnodes.add(esd.getNode());
				uplist.add(esd);
			}else{
				downnodes.add(esd.getNode());
				downlist.add(esd);
			}
		}
	}
	@XmlTransient
	public List<EleSourceDirection> getEleSourceDirectionList() {
		return eleSourceDirectionList;
	}

	public void setEleSourceDirectionList(List<EleSourceDirection> eleSourceDirectionList) {
		this.eleSourceDirectionList = eleSourceDirectionList;
	}
}